/**
 * 网络请求封装
 * @param url
 * @param body
 * @param method
 */

import config from 'config'

function request(url,body,method) {
    url = config.server + url
    return new Promise(((resolve, reject) => {
        fetch(url,{
            method:method,
            body:JSON.stringify(body),
            headers:{
                'Content-Type': 'application/json'
            }
        }).then(res=>{
            resolve(res.json())
        }).catch(error=>{
            reject(error)
        })
    }))
}

export default request



